package com.wjsima.renyisima.demo;

import java.text.DateFormat;
import java.text.Format;
import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
import java.util.Calendar;
import java.util.Date;
import java.util.HashSet;
import java.util.Random;
import java.util.function.Supplier;

public class HomeWork {
    public static <T> T getObj(Supplier<T> supplier) {
        return supplier.get();
    }



    public static void main(String[] args) {
        String[] st = getObj(() -> new String[5]);
        System.out.println(st.length);
        HashSet hs = getObj((Supplier<HashSet>) () -> {
            Random r = new Random();
            HashSet<Integer> hs1 = new HashSet<>();
//            for (int i = 0; i < 5; i++) {
//
//                hs1.add(r.nextInt(20) + 1);
//
//           }
            while(hs1.size() != 5){
                hs1.add(r.nextInt(20) + 1);
            }
            return hs1;
        });
        System.out.println(hs);
//        一个代表2018年4月1日的Calendar对象r
        Calendar r1 = getObj(() -> {
            Calendar instance = Calendar.getInstance();
            instance.set(2018,04,01);
            return instance;
        });




    }
}